package simplechat.client;

import javax.swing.*;
import java.awt.*;

/**
 * @program: netty-study
 * @description: 客户端图形化界面
 * @author: 胡海龙
 * @create: 2021-04-11 11:44:54
 **/
public class LoginFrame extends JFrame {

    private JPanel panel;

    public LoginFrame(){
        addComponent();
        getContentPane().add(panel);
        setSize(400,100);
        setTitle("聊天测试");
        setVisible(true);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    private void addComponent(){
        panel = new JPanel();
        JTextField username = new JTextField();
        JLabel usernameLabel = new JLabel("username");
        username.setColumns(9);
        JButton login = new JButton("连接");
        login.addActionListener(e -> {
            this.dispose();
            new MainFrame();
        });
        panel.add(usernameLabel,BorderLayout.CENTER);
        panel.add(username,BorderLayout.CENTER);
        panel.add(login, BorderLayout.SOUTH);
    }

    public static void main(String[] args) {
        new LoginFrame();
    }
}
